package debtbundler.mathematics;

import java.util.Arrays;

public class MatrixToString {
	
	/**
	 * Creates a string representation of an array, e.g.
	 * <code>"[2.4, 1.2, 324]"</code>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(Object[] array) {
		return Arrays.toString(array);
	}
	
	/**
	 * Creates a string representation of an array, e.g.
	 * <code>"[2.4, 1.2, 324]"</code>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(int[] array) {
		return Arrays.toString(array);
	}
	
	/**
	 * Creates a string representation of an array, e.g.
	 * <code>"[2.4, 1.2, 324]"</code>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(double[] array) {
		return Arrays.toString(array);
	}	

	/**
	 * Creates a string representation of an array, e.g.
	 * <code>"[2.4, 1.2, 324]"</code>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(long[] array) {
		return Arrays.toString(array);
	}
	
	/**
	 * Creates a string representation of an array, e.g.
	 * <code>"[2.4, 1.2, 324]"</code>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(float[] array) {
		return Arrays.toString(array);
	}	
	
	/**
	 * Creates a string representation of an array, e.g.
	 * <code>"[2.4, 1.2, 324]"</code>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(short[] array) {
		return Arrays.toString(array);
	}
	
	/**
	 * Creates a string representation of an array, e.g.
	 * <code>"[2.4, 1.2, 324]"</code>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(boolean[] array) {
		return Arrays.toString(array);
	}	
	
	/**
	 * Creates a string representation of a matrix, e.g.
	 * <pre>
	 * "[2.4, 1.2, 324]
	 *  [0.1, 5.33, 4245]
	 *  [45, 24.34, 94.4]"
	 * </pre>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(Object[][] matrix) {
		StringBuffer sb = new StringBuffer();
		for (int row = 0; row < matrix.length; row++) {
			sb.append(toString(matrix[row]));
		}
		return sb.toString();
	}	
	
	/**
	 * Creates a string representation of a matrix, e.g.
	 * <pre>
	 * "[2.4, 1.2, 324]
	 *  [0.1, 5.33, 4245]
	 *  [45, 24.34, 94.4]"
	 * </pre>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(int[][] matrix) {
		StringBuffer sb = new StringBuffer();
		for (int row = 0; row < matrix.length; row++) {
			sb.append(toString(matrix[row]));
		}
		return sb.toString();
	}
	
	/**
	 * Creates a string representation of a matrix, e.g.
	 * <pre>
	 * "[2.4, 1.2, 324]
	 *  [0.1, 5.33, 4245]
	 *  [45, 24.34, 94.4]"
	 * </pre>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(double[][] matrix) {
		StringBuffer sb = new StringBuffer();
		for (int row = 0; row < matrix.length; row++) {
			sb.append(toString(matrix[row]));
		}
		return sb.toString();
	}

	/**
	 * Creates a string representation of a matrix, e.g.
	 * <pre>
	 * "[2.4, 1.2, 324]
	 *  [0.1, 5.33, 4245]
	 *  [45, 24.34, 94.4]"
	 * </pre>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(long[][] matrix) {
		StringBuffer sb = new StringBuffer();
		for (int row = 0; row < matrix.length; row++) {
			sb.append(toString(matrix[row]));
		}
		return sb.toString();
	}
	
	/**
	 * Creates a string representation of a matrix, e.g.
	 * <pre>
	 * "[2.4, 1.2, 324]
	 *  [0.1, 5.33, 4245]
	 *  [45, 24.34, 94.4]"
	 * </pre>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(float[][] matrix) {
		StringBuffer sb = new StringBuffer();
		for (int row = 0; row < matrix.length; row++) {
			sb.append(toString(matrix[row]));
		}
		return sb.toString();
	}
	
	/**
	 * Creates a string representation of a matrix, e.g.
	 * <pre>
	 * "[2.4, 1.2, 324]
	 *  [0.1, 5.33, 4245]
	 *  [45, 24.34, 94.4]"
	 * </pre>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(short[][] matrix) {
		StringBuffer sb = new StringBuffer();
		for (int row = 0; row < matrix.length; row++) {
			sb.append(toString(matrix[row]));
		}
		return sb.toString();
	}
	
	/**
	 * Creates a string representation of a matrix, e.g.
	 * <pre>
	 * "[2.4, 1.2, 324]
	 *  [0.1, 5.33, 4245]
	 *  [45, 24.34, 94.4]"
	 * </pre>.
	 * 
	 * @param array	array to get a string representation of
	 * @return		the string representation of <code>array</code>
	 */
	public static String toString(boolean[][] matrix) {
		StringBuffer sb = new StringBuffer();
		for (int row = 0; row < matrix.length; row++) {
			sb.append(toString(matrix[row]));
		}
		return sb.toString();
	}
	
}
